﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace THenu.TinyHourseLib.DesignPattern.Behavioral_Patterns.Template_Method
{
    class TemplateMethod : IPatternDemonstrate
    {
        public void StructuralCode()
        {
            AbstractClass aA = new ConcreteClassA();
            aA.TemplateMethod();

            AbstractClass aB = new ConcreteClassB();
            aB.TemplateMethod();
        }

        public string PatternDescription()
        {
            string description = @"
Definition
Define the skeleton of an algorithm in an operation, deferring some steps to subclasses. Template Method lets subclasses redefine certain steps of an algorithm without changing the algorithm's structure.

Participants

    The classes and objects participating in this pattern are:

AbstractClass  (DataObject)
·defines abstract primitive operations that concrete subclasses define to implement steps of an algorithm
·implements a template method defining the skeleton of an algorithm. The template method calls primitive operations as well as operations defined in AbstractClass or those of other objects.
ConcreteClass  (CustomerDataObject)
·implements the primitive operations ot carry out subclass-specific steps of the algorithm";
            return description;
        }

        public void RealWorldExample()
        {
            DataAccessObject daoCategories = new Categories();
            daoCategories.Run();

            DataAccessObject daoProducts = new Products();
            daoProducts.Run();


        }
    }
}
